<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul {
            color: #000;
        }

        .parent div {
            height: 100px;
            width: 100px;
        }

        .html {
            background-color: aqua;
        }

        .css {
            background-color: coral;
        }

        .current {
            color: crimson;
        }
    </style>
</head>

<body>
    <ul>
        <li>html</li>
        <li>css</li>
    </ul>
    <div class="parent">
        <div class="html"></div>
        <div class="css"></div>
    </div>

    <script>
        var li = document.getElementsByTagName("li");
        var divs = document.querySelectorAll(".parent div");
        for (let i = 0; i < li.length; i++) {
            li[i].index = i;
            console.log(li[i]);
            li[i].onclick = function () {
                console.log(this.index);
                for (let i = 0; i < li.length; i++) {
                    li[i].classList.remove("current");
                }
                this.classList.add("current");

                for (let i = 0; i < divs.length; i++) {
                    divs[i].style.display = "none";

                }
                divs[this.index].style.display = "block";

            }
        }
    </script>
</body>

</html>